package com.hospital.dictionary.module.controller;


import com.alibaba.fastjson.JSON;
import com.hospital.common.core.result.SuccessTip;
import com.hospital.common.core.result.Tip;
import com.hospital.dictionary.module.controller.base.BaseController;
import com.hospital.dictionary.module.controller.dto.ClinicItemVo;
import com.hospital.dictionary.module.controller.dto.ItemDate;
import com.hospital.dictionary.module.entity.ClinicItemNameDict;
import com.hospital.dictionary.module.service.BillItemClassDictService;
import com.hospital.dictionary.module.service.ClinicItemNameDictService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lvyao
 * @since 2022-02-14
 */
@RestController
@RequestMapping("/module/clinicItemNameDict")
public class ClinicItemNameDictController extends BaseController<ClinicItemNameDict, ClinicItemNameDictService> {
    @Resource
    private ClinicItemNameDictService clinicItemNameDictService;

    @Resource
    private BillItemClassDictService billItemClassDictService;

    @PostMapping(value = "/getInfoByCode")
    public Tip saveRolePermission(@RequestBody String param) {
        List<ClinicItemNameDict> clinicItemNameDicts = new ArrayList<>();
        ClinicItemVo clinicItemVo = JSON.parseObject(param,ClinicItemVo.class);
        for (ItemDate itemDate : clinicItemVo.getItemList()) {
            List<ClinicItemNameDict> list = clinicItemNameDictService.listBycode(itemDate.getItemCode(),itemDate.getItemClass());
            clinicItemNameDicts.addAll(list);
        }
        return new SuccessTip(clinicItemNameDicts);
    }


}

